<template>
  <div class="list">
    <list-header></list-header>
    <list-content :goodsList="goodsList"></list-content>
  </div>
</template>

<script>
import axios from 'axios'
import ListHeader from './components/ListHeader'
import ListContent from './components/ListContent'
export default {
  name: 'List',
  data () {
    return {
      goodsList:[]
    }
  },
  components:{
     ListHeader,
     ListContent,
  },
  mounted(){
    this.getHomeInfo()
  },
  methods:{
    getHomeInfo(){
        // axios返回的结果是一个promise对象
        axios.get('/shopping_mall/index.php/Home/List/index').then(
        // 注意：这里绝对不可以写成this.getHomeInfoSucc（），否则请求的结果会是undefined
        this.getHomeInfoSucc
      )
    },
    getHomeInfoSucc(res){
        // console.log(res)
        res = res.data 
        // console.log(res)
        if(res.ret && res.data){
          this.goodsList = res.data.goodsList
        }
    }
  }
}
</script>


<style lang="stylus" scoped>
.list 
    background-color #efefef
</style>
